﻿using System;
using System.Xml.Serialization;
using MergeTI.TiEntityObjects;
using TI;
using TI_EntityLib.TiEntityObjects;

namespace TiPort.TiEntityObjects
{
    public class DictionaryOrganization : IDbRootObject
    {
        [XmlElement("regNumber")]
        public string  RegNumber { get; set; }

        public string Key { get { return RegNumber; } }

        [XmlElement("shortName")]
        public string ShortName { get; set; }

        [XmlElement("fullName")]
        public string FullName { get; set; }

        [XmlElement("email")]
        public string Email { get; set; }

        [XmlElement("phone")]
        public string Phone { get; set; }

        [XmlElement("fax")]
        public string Fax{ get; set; }

        [XmlElement("inn")]
        public string Inn { get; set; }

        [XmlElement("kpp")]
        public string Kpp { get; set; }

        [XmlElement("ogrn")]
        public string Ogrn { get; set; }

        [XmlElement("OKPO")]
        public string OKPO { get; set; }

        [XmlElement("OKVED")]
        public string OKVED { get; set; }

        [XmlElement("organizationRole")]
        public string OrganizationRole { get; set; }

        [XmlElement("timeZone")]
        public int TimeZone { get; set; }
        

        [XmlElement("factualAddress")]        
        public DictionaryFactualAddress FactualAddress { get; set; }

        [XmlElement("orderingAgency")]
        [LinkObjectAttribute(ChildFieldName = "RegNum", IsDictionaryValue = true, IsPartialObject = false, ParentFieldName = "OrderingAgencyID")]        
        public OrderingAgency OrderingAgency { get; set; }
        public string OrderingAgencyID { get; set; }

        [XmlElement("okopf")]
        [LinkObjectAttribute(ChildFieldName = "Code", IsDictionaryValue = true, IsPartialObject = false, ParentFieldName = "OkopfID")]        
        public DictionaryOkopf  Okopf { get; set; }
        public string OkopfID { get; set; }


        [XmlElement("organizationType")]
        [LinkObjectAttribute(ChildFieldName = "ID", IsDictionaryValue = true, IsPartialObject = false, ParentFieldName = "OrganizationTypeID")]
        public DictionaryOrganizationType OrganizationType { get; set; }
        public string OrganizationTypeID { get; set; }

        [XmlElement("subordinationType")]
        [LinkObjectAttribute(ChildFieldName = "ID", IsDictionaryValue = true, IsPartialObject = false, ParentFieldName = "DictionarySubordinationTypeID")]
        public DictionarySubordinationType DictionarySubordinationType { get; set; }
        public string DictionarySubordinationTypeID { get; set; }

        [XmlElement("accounts")]
        [LinkObjectAttribute( IsCollection = true)]
        public DictionaryOrganizationAccounts Accounts { get; set; }
        

        public DateTime LastUpdateDate
        {
            get
            {
                return DateTime.Now;
            }
            set
            {
                ;
            }
        }

        public string FileName { get; set; }

        public string ObjectType { get;set;}

        public long iFileDate { get; set; }

       

        #region IDbRootObject Members


        public TiEntityClass Class
        {
            get { return TiEntityClass.None; }
        }

        #endregion


        public string GetInsertScript()
        {
            throw new NotImplementedException();
        }

        public override string ToString()
        {
            return Helper.Json<DictionaryOrganization>.Serialize(this);
        }



        public long iTransportDay
        {
            get;
            set;
        }
    }
}
